package net.simflow.swf.analyzer.chart;

import java.util.Collection;
import java.util.TreeMap;

import net.simflow.swf.analyzer.data.DataPkg;
import net.simflow.swf.analyzer.exec.stats.data.ExecStats;
import net.simflow.swf.analyzer.network.data.Flow;

import org.eclipse.swt.widgets.Display;

public class ExecStatsChart {

	private static ExecStatsChart instance = new ExecStatsChart();

	private ExecStatsChart() {
	}

	public static ExecStatsChart getInstance() {
		return instance;
	}

	public void create(String style, Display display, String title,
			String xAxisTitle, String yAxisTitle, DataPkg dataPkg) {
		try {
			title = title + ": " + style;
			switch (style) {
			case ExecStats.EXECUTION_TIME_DISTRIBUTION:
				this.createExecTimeDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg
								.getNetworkExecResultPkg().getExecStats()
								.getExecTimeDistribution());
				break;
			case ExecStats.FLOW_TOTAL_COUNT:
				this.createFlowCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.FLOW_EXECUTED_COUNT:
				this.createFlowCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.FLOW_UNFINISHED_COUNT:
				this.createFlowCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.FLOW_TOTAL_COUNT_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg
								.getNetworkExecResultPkg().getExecStats()
								.getFlowTotalCountDistribution());
				break;
			case ExecStats.FLOW_EXECUTED_COUNT_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg
								.getNetworkExecResultPkg().getExecStats()
								.getFlowExecCountDistribution());
				break;
			case ExecStats.FLOW_UNFINISHED_COUNT_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg
								.getNetworkExecResultPkg().getExecStats()
								.getFlowUnfinishedCountDistribution());
				break;
			case ExecStats.FLOW_OVER_ABILITY_TIME:
				this.createFlowOverAbilityMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.FLOW_OVER_ABILITY_TIME_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg
								.getNetworkExecResultPkg().getExecStats()
								.getFlowOverAbilityTimeDistribution());
				break;
			case ExecStats.SERVICE_TOTAL_COUNT:
				this.createServiceCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_EXECUTED_COUNT:
				this.createServiceCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_UNFINISHED_COUNT:
				this.createServiceCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_TOTAL_COUNT_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_EXECUTED_COUNT_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_UNFINISHED_COUNT_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_WAIT_TIME:
				this.createServiceWaitTimeMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_MAX_WAIT_TIME_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_MIN_WAIT_TIME_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_AVG_WAIT_TIME_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_OVER_ABILITY_TIME:
				this.createServiceCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.SERVICE_OVER_ABILITY_TIME_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.FLOW_EXEC_TIME:
				this.createFlowExecTimeMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg);
				break;
			case ExecStats.FLOW_MAX_EXEC_TIME_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg
								.getNetworkExecResultPkg().getExecStats()
								.getFlowMaxExecTimeDistribution());
				break;
			case ExecStats.FLOW_MIN_EXEC_TIME_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg
								.getNetworkExecResultPkg().getExecStats()
								.getFlowMinExecTimeDistribution());
				break;
			case ExecStats.FLOW_AVG_EXEC_TIME_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg
								.getNetworkExecResultPkg().getExecStats()
								.getFlowAvgExecTimeDistribution());
				break;
			}
		} catch (Exception ee) {
			return;
		}
	}

	public void create(String style, Display display, String title,
			String xAxisTitle, String yAxisTitle, DataPkg dataPkg, Flow flow) {
		try {
			title = title + ": " + style;
			switch (style) {
			case ExecStats.EXECUTION_TIME_DISTRIBUTION:
				this.createExecTimeDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_TOTAL_COUNT:
				this.createFlowCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_EXECUTED_COUNT:
				this.createFlowCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_UNFINISHED_COUNT:
				this.createFlowCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_TOTAL_COUNT_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_EXECUTED_COUNT_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_UNFINISHED_COUNT_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_OVER_ABILITY_TIME:
				this.createFlowOverAbilityMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_OVER_ABILITY_TIME_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_TOTAL_COUNT:
				this.createServiceCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_EXECUTED_COUNT:
				this.createServiceCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_UNFINISHED_COUNT:
				this.createServiceCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_TOTAL_COUNT_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_EXECUTED_COUNT_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_UNFINISHED_COUNT_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_WAIT_TIME:
				this.createServiceWaitTimeMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_MAX_WAIT_TIME_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_MIN_WAIT_TIME_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_AVG_WAIT_TIME_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_OVER_ABILITY_TIME:
				this.createServiceCountMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.SERVICE_OVER_ABILITY_TIME_DISTRIBUTION:
				this.createServiceDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_EXEC_TIME:
				this.createFlowExecTimeMapString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_MAX_EXEC_TIME_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_MIN_EXEC_TIME_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			case ExecStats.FLOW_AVG_EXEC_TIME_DISTRIBUTION:
				this.createFlowDistributionString(style, display, title,
						xAxisTitle, yAxisTitle, dataPkg, flow);
				break;
			}
		} catch (Exception ee) {
			return;
		}
	}

	private void createExecTimeDistributionString(
			String style,
			Display display,
			String title,
			String xAxisTitle,
			String yAxisTitle,
			TreeMap<? extends Number, ? extends Collection<? extends Object>> dis) {
		StatsChart.getInstance().drawDistributionChart(display, title,
				xAxisTitle, yAxisTitle, dis);

	}

	private void createExecTimeDistributionString(String style,
			Display display, String title, String xAxisTitle,
			String yAxisTitle, DataPkg dataPkg, Flow flow) {

	}

	private void createServiceCountMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle, DataPkg dataPkg) {

	}

	private void createServiceCountMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle,
			DataPkg dataPkg, Flow flow) {

	}

	private void createServiceWaitTimeMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle, DataPkg dataPkg) {

	}

	private void createServiceWaitTimeMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle,
			DataPkg dataPkg, Flow flow) {

	}

	private void createServiceDistributionString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle, DataPkg dataPkg) {

	}

	private void createServiceDistributionString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle,
			DataPkg dataPkg, Flow flow) {

	}

	private void createFlowCountMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle, DataPkg dataPkg) {

	}

	private void createFlowCountMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle,
			DataPkg dataPkg, Flow flow) {

	}

	private void createFlowDistributionString(
			String style,
			Display display,
			String title,
			String xAxisTitle,
			String yAxisTitle,
			TreeMap<? extends Number, ? extends Collection<? extends Object>> dis) {
		StatsChart.getInstance().drawDistributionChart(display, title,
				xAxisTitle, yAxisTitle, dis);
	}

	private void createFlowDistributionString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle,
			DataPkg dataPkg, Flow flow) {

	}

	private void createFlowOverAbilityMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle, DataPkg dataPkg) {

	}

	private void createFlowOverAbilityMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle,
			DataPkg dataPkg, Flow flow) {

	}

	private void createFlowExecTimeMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle, DataPkg dataPkg) {

	}

	private void createFlowExecTimeMapString(String style, Display display,
			String title, String xAxisTitle, String yAxisTitle,
			DataPkg dataPkg, Flow flow) {

	}
}
